#include "Program.h"

#include <compilation/task/ScopeTask.h>


namespace compilation
{


void
Program::setScopes(void)
{
  UNSET_DEBUG_FOR_VISITORS();

  if (debug_instruction_visitor)
    std::cout
      << "setScopes:\n"
         "----------\n";

  ScopeAgenda::instruction_handler_visitor_type sihv =
      ScopeAgenda::instruction_handler_visitor_type
      ::build_visitor<ScopeInstructionHandler>();

  ScopeAgenda::instruction_propagator_visitor_type sipv =
      ScopeAgenda::instruction_propagator_visitor_type
      ::build_visitor<DefaultInstructionPropagator
      <ScopeTask, ScopeAgenda>::type>();

  for (Function const& fn : m_functions)
  {
    if (debug_instruction_visitor)
      std::cout
          << "ScopeAgenda: " << fn.getName() << std::endl
          << "°°°°°°°°°°°°\n";
    ScopeAgenda sAgenda(sihv, sipv, fn);
    execute(sAgenda);
  }
}


} // compilation
